#ifndef __SOCKET_H__
#define __SOCKET_H__
#include <string>

#ifdef WIN32
#   include <winsock2.h>
#   include<Ws2tcpip.h>
#include <mstcpip.h>
#else
#   include <sys/socket.h>
#   include <netinet/in.h>
#   include <arpa/inet.h>
#   include <unistd.h>
#   include <stdlib.h>
#   include <string.h>
#endif

#define BUF_SIZE 1024

typedef unsigned short port_t;

#ifdef _WIN32
typedef unsigned long long mSOCKET;
#else
typedef int mSOCKET;
#endif

using namespace std;

class address
{
public:
    address() { m_iPort = -1; m_strIp = ""; }
    address(const string& ip, port_t port)
    {
        m_strIp = ip;
        m_iPort = port;
    }
    string m_strIp;
    port_t m_iPort;
};
struct sockaddr_in* to_sockaddr(address* a);

address* from_sockaddr(struct sockaddr_in* addr);

typedef void (*recv_callback)(const std::string& data, mSOCKET s);

#endif